package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.danmo.domain.DanmoTariningWorks;
import com.muyu.danmo.service.IDanmoTariningWorksService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 培训班作品照片Controller
 *
 * @author yangle
 * @date 2024-10-21
 */
@RestController
@RequestMapping("/tariningWorks")
public class DanmoTariningWorksController extends BaseController
{
    @Autowired
    private IDanmoTariningWorksService danmoTariningWorksService;

    /**
     * 查询培训班作品照片列表
     */
//    @RequiresPermissions("system:tariningWorks:list")
    @GetMapping("/list")
    public Result<TableDataInfo<DanmoTariningWorks>> list(DanmoTariningWorks danmoTariningWorks)
    {
        startPage();
        List<DanmoTariningWorks> list = danmoTariningWorksService.selectDanmoTariningWorksList(danmoTariningWorks);
        return getDataTable(list);
    }

    /**
     * 导出培训班作品照片列表
     */
//    @RequiresPermissions("system:tariningWorks:export")
    @Log(title = "培训班作品照片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoTariningWorks danmoTariningWorks)
    {
        List<DanmoTariningWorks> list = danmoTariningWorksService.selectDanmoTariningWorksList(danmoTariningWorks);
        ExcelUtil<DanmoTariningWorks> util = new ExcelUtil<DanmoTariningWorks>(DanmoTariningWorks.class);
        util.exportExcel(response, list, "培训班作品照片数据");
    }

    /**
     * 获取培训班作品照片详细信息
     */
//    @RequiresPermissions("system:tariningWorks:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoTariningWorksService.selectDanmoTariningWorksById(id));
    }

    /**
     * 新增培训班作品照片
     */
//    @RequiresPermissions("system:tariningWorks:add")
    @Log(title = "培训班作品照片", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoTariningWorks danmoTariningWorks)
    {
        return toAjax(danmoTariningWorksService.insertDanmoTariningWorks(danmoTariningWorks));
    }

    /**
     * 修改培训班作品照片
     */
//    @RequiresPermissions("system:tariningWorks:edit")
    @Log(title = "培训班作品照片", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoTariningWorks danmoTariningWorks)
    {
        return toAjax(danmoTariningWorksService.updateDanmoTariningWorks(danmoTariningWorks));
    }

    /**
     * 删除培训班作品照片
     */
//    @RequiresPermissions("system:tariningWorks:remove")
    @Log(title = "培训班作品照片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoTariningWorksService.deleteDanmoTariningWorksByIds(ids));
    }
}
